package top.readhub.wopei.manager.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import top.readhub.wopei.manager.dal.model.SettingConfigPO;
import top.readhub.wopei.manager.dal.model.SettingRecordPO;
import top.readhub.wopei.manager.service.ISettingConfigService;

@RestController
@RequestMapping("/manager")
public class AdminController {
    @Autowired
    private ISettingConfigService settingService;

    @RequestMapping("/add")
    public Long add(@RequestBody SettingConfigPO op) {
        return settingService.add(op);
    }

    @RequestMapping("/del")
    public Integer del(@RequestBody Long id) {
        return settingService.del(id);
    }

    @RequestMapping("/addFilter")
    public Long addFilter(@RequestBody SettingConfigPO op) {
        return settingService.add(op);
    }

    @RequestMapping("/saveRecord")
    public Number saveRecord(@RequestBody SettingRecordPO po) {
        if (po.getId() == null || po.getId() <= 0) {
            return settingService.addRecord(po);
        }
        return settingService.updateRecord(po);
    }
}
